/**
 * msg***:自动消失提示消息
 * alert***：需要点击确认的提示消息
 */

(function ($) {
    $.extend({
        alertMsg: {
            // 显示图标
            icon: function (type) {
                var icon = "";
                if (type == alertMsg_status.WARNING) {
                    icon = 0;
                } else if (type == alertMsg_status.SUCCESS) {
                    icon = 1;
                } else if (type == alertMsg_status.FAIL) {
                    icon = 2;
                } else if (type == alertMsg_status.QUEST) {
                    icon = 3;
                } else if (type == alertMsg_status.LOCKED) {
                    icon = 4;
                } else {
                    icon = 3;
                }
                return icon;
            },
            // 消息提示
            msg: function (content, type) {
                if (type != undefined) {
                    layer.msg(content, {icon: $.alertMsg.icon(type), time: 1000, shift: 5});
                } else {
                    layer.msg(content);
                }
            },
            // 错误消息
            msgError: function (content) {
                $.alertMsg.msg(content, alertMsg_status.FAIL);
            },
            // 成功消息
            msgSuccess: function (content) {
                $.alertMsg.msg(content, alertMsg_status.SUCCESS);
            },
            // 警告消息
            msgWarning: function (content) {
                $.alertMsg.msg(content, alertMsg_status.WARNING);
            },
            // 弹出提示
            alert: function (content, type) {
                layer.alert(content, {
                    icon: $.alertMsg.icon(type),
                    title: "系统提示",
                    btn: ['确认'],
                    btnclass: ['btn btn-primary'],
                });
            },
            // 错误提示
            alertError: function (content) {
                $.alertMsg.alert(content, alertMsg_status.FAIL);
            },
            // 成功提示
            alertSuccess: function (content) {
                $.alertMsg.alert(content, alertMsg_status.SUCCESS);
            },
            // 警告提示
            alertWarning: function (content) {
                $.alertMsg.alert(content, alertMsg_status.WARNING);
            },
            // 确认窗体
            confirm: function (content, callBack) {
                layer.confirm(content, {
                    icon: 3,
                    title: "系统提示",
                    btn: ['确认', '取消'],
                    btnclass: ['btn btn-primary', 'btn btn-danger'],
                }, function (index) {
                    layer.close(index);
                    callBack(true);
                });
            },
        }
    });
})(jQuery);
/** 弹窗状态码 */
alertMsg_status = {
    SUCCESS: "success",
    FAIL: "error",
    WARNING: "warning",
    QUEST: "quest",
    LOCKED: "locked"
};